<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    <title>动态代理机制详解 | 奔跑的蜗牛 | 虚心若愚</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="动态代理">
    <meta name="description" content="转自：java的动态代理机制详解 动态代理机制详解在学习Spring的时候，我们知道Spring主要有两大思想，一个是IoC，另一个就是AOP，对于IoC，依赖注入就不用多说了，而对于Spring的核心AOP来说，我们不但要知道怎么通过AOP来满足的我们的功能，我们更需要学习的是其底层是怎么样的一个原理，而AOP的原理就是java的动态代理机制，所以本篇随笔就是对java的动态机制进行一个回顾。">
<meta name="keywords" content="动态代理">
<meta property="og:type" content="article">
<meta property="og:title" content="动态代理机制详解">
<meta property="og:url" content="http://windynature.oschina.io/2016/10/04/java/动态代理/index.html">
<meta property="og:site_name" content="奔跑的蜗牛">
<meta property="og:description" content="转自：java的动态代理机制详解 动态代理机制详解在学习Spring的时候，我们知道Spring主要有两大思想，一个是IoC，另一个就是AOP，对于IoC，依赖注入就不用多说了，而对于Spring的核心AOP来说，我们不但要知道怎么通过AOP来满足的我们的功能，我们更需要学习的是其底层是怎么样的一个原理，而AOP的原理就是java的动态代理机制，所以本篇随笔就是对java的动态机制进行一个回顾。">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2020-03-18T04:04:10.760Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="动态代理机制详解">
<meta name="twitter:description" content="转自：java的动态代理机制详解 动态代理机制详解在学习Spring的时候，我们知道Spring主要有两大思想，一个是IoC，另一个就是AOP，对于IoC，依赖注入就不用多说了，而对于Spring的核心AOP来说，我们不但要知道怎么通过AOP来满足的我们的功能，我们更需要学习的是其底层是怎么样的一个原理，而AOP的原理就是java的动态代理机制，所以本篇随笔就是对java的动态机制进行一个回顾。">
    
        <link rel="alternative" href="/atom.xml" title="奔跑的蜗牛" type="application/atom+xml">
    
    <link rel="shortcut icon" href="/blog/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@1.5.2/css/style.css">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/blog/img/timg.jpg)">
      <div class="brand">
        <a href="/blog/" class="avatar waves-effect waves-circle waves-light">
          <img src="/blog/img/user2.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">windy</h5>
          <a href="mailto:windynature@163.com" title="windynature@163.com" class="mail">windynature@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/blog/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/WindyNature" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://git.oschina.net/windynature" target="_blank" >
                <i class="icon icon-lg icon-mayun"></i>
                码云
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">动态代理机制详解</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">动态代理机制详解</h1>
        <h5 class="subtitle">
            
                <time datetime="2016-10-03T17:40:14.000Z" itemprop="datePublished" class="page-time">
  2016-10-04
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/blog/categories/设计模式/">设计模式</a></li></ul>

            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#动态代理机制详解"><span class="post-toc-text">动态代理机制详解</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#InvocationHandler"><span class="post-toc-text">InvocationHandler</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Proxy"><span class="post-toc-text">Proxy</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#JDK动态代理实现"><span class="post-toc-text">JDK动态代理实现</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#定义接口和实现"><span class="post-toc-text">定义接口和实现</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#jdk动态代理实现"><span class="post-toc-text">jdk动态代理实现</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#代码分析"><span class="post-toc-text">代码分析</span></a></li></ol></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-java/动态代理"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">动态代理机制详解</h1>
        <div class="post-meta">
            <time class="post-time" title="2016年10月04日 1:40" datetime="2016-10-03T17:40:14.000Z"  itemprop="datePublished">2016-10-04</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/blog/categories/设计模式/">设计模式</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <p>转自：<a href="http://www.cnblogs.com/xiaoluo501395377/p/3383130.html" target="_blank" rel="noopener">java的动态代理机制详解</a></p>
<h1 id="动态代理机制详解"><a href="#动态代理机制详解" class="headerlink" title="动态代理机制详解"></a>动态代理机制详解</h1><p>在学习Spring的时候，我们知道Spring主要有两大思想，一个是<code>IoC</code>，另一个就是<code>AOP</code>，对于IoC，依赖注入就不用多说了，而对于Spring的核心AOP来说，我们不但要知道怎么通过AOP来满足的我们的功能，我们更需要学习的是其底层是怎么样的一个原理，而<code>AOP的原理就是java的动态代理机制</code>，所以本篇随笔就是对java的动态机制进行一个回顾。</p>
<h2 id="InvocationHandler"><a href="#InvocationHandler" class="headerlink" title="InvocationHandler"></a>InvocationHandler</h2><p>在java的动态代理机制中，有两个重要的类或接口，一个是 <code>InvocationHandler(Interface)</code>、另一个则是 <code>Proxy(Class)</code>，这一个类和接口是实现我们动态代理所必须用到的。首先我们先来看看java的API帮助文档是怎么样对这两个类进行描述的：</p>
<blockquote>
<p>InvocationHandler is the interface implemented by the invocation handler of a proxy instance. </p>
<p>Each proxy instance has an associated invocation handler. When a method is invoked on a proxy instance, the method invocation is encoded and dispatched to the invoke method of its invocation handler.</p>
</blockquote>
<p>每一个动态代理都必须要实现<code>InvocationHandler</code>这个接口，并且每个代理类的实例都关联到了一个<code>handler</code>。当我们通过代理对象调用一个方法的时候，这个方法的调用就会被转发为由<code>InvocationHander</code>这个接口的<code>invoke()</code>方法来进行调用。我们来看看<code>InvocationHandler</code>这个接口的唯一一个<code>invoke()</code>方法：</p>
<h2 id="Proxy"><a href="#Proxy" class="headerlink" title="Proxy"></a>Proxy</h2><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="function">Object <span class="title">invoke</span><span class="params">(Object proxy, Method method, Object[] args)</span> <span class="keyword">throws</span> Throwable</span></span><br></pre></td></tr></table></figure>

<p>我满看到这个方法一共接收三个参数，那么这三个参数分别代表什么呢？</p>
<blockquote>
<ul>
<li><code>proxy:</code>指代我们所代理的那个正式对象</li>
<li><code>method:</code>指代的是我们所要调用真实对象的牟飞方法的Method对象。</li>
<li><code>args:</code>指代的是调用真实对象某个方法时接受的参数。</li>
</ul>
</blockquote>
<p>接下来看看<code>Proxy</code>类：</p>
<blockquote>
<p>Proxy provides static methods for <code>creating dynamic proxy classes and instances</code>, and <code>it is also the superclass of all dynamic proxy classes</code> created by those methods. </p>
</blockquote>
<p><code>Proxy</code> 类的作用是：用来创建一个代理对象的类，它提供了许多方法，但是我们用的最多的就是<code>newProxyInstance()</code>这个方法。</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Object <span class="title">newProxyInstance</span><span class="params">(ClassLoader loader, Class&lt;?&gt;[] interfaces,</span></span></span><br><span class="line"><span class="function"><span class="params">  InvocationHandler h)</span>  <span class="keyword">throws</span> IllegalArgumentException</span></span><br></pre></td></tr></table></figure>

<blockquote>
<p>Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to the specified invocation handler.</p>
</blockquote>
<p>这个方法的作用就是得到一个动态代理对象，它接收三个参数，含义如下</p>
<blockquote>
<p><code>loader:</code>一个<code>ClassLoader</code>对象，定义了由那个<code>ClassLoader</code>对象对生成的代理对象进行加载。<br><code>interface:</code>一个<code>Ingerface</code>对象的数组，表示的是我们要将给我需要代理的对象提供一组什么接口，如果我提供了一组接口给它，那么这个代理对象就应实现该接口（多态），这样我们就能调用这组接口中的方法了。<br><code>h:</code>一个<code>InvocationHandler</code>对象，表示的是当我这个动态代理对象在调用方法的时候，会关联到哪一个<code>InvocationHandler</code>对象上。</p>
</blockquote>
<h2 id="JDK动态代理实现"><a href="#JDK动态代理实现" class="headerlink" title="JDK动态代理实现"></a>JDK动态代理实现</h2><p>引用自 <a href="http://blog.csdn.net/heyutao007/article/details/49738887" target="_blank" rel="noopener">Java动态代理的两种实现方法</a></p>
<h3 id="定义接口和实现"><a href="#定义接口和实现" class="headerlink" title="定义接口和实现"></a>定义接口和实现</h3><p><strong>UserService接口</strong></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">UserService</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getName</span><span class="params">(<span class="keyword">int</span> id)</span></span>;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> Integer <span class="title">getAge</span><span class="params">(<span class="keyword">int</span> id)</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>UserServiceImpl</strong></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UserServiceImpl</span> <span class="keyword">implements</span> <span class="title">UserService</span> </span>&#123;</span><br><span class="line">     <span class="meta">@Override</span>  </span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getName</span><span class="params">(<span class="keyword">int</span> id)</span> </span>&#123;  </span><br><span class="line">        System.out.println(<span class="string">"------getName------"</span>);  </span><br><span class="line">        <span class="keyword">return</span> <span class="string">"Tom"</span>;  </span><br><span class="line">    &#125;  </span><br><span class="line">  </span><br><span class="line">    <span class="meta">@Override</span>  </span><br><span class="line">    <span class="function"><span class="keyword">public</span> Integer <span class="title">getAge</span><span class="params">(<span class="keyword">int</span> id)</span> </span>&#123;  </span><br><span class="line">        System.out.println(<span class="string">"------getAge------"</span>);  </span><br><span class="line">        <span class="keyword">return</span> <span class="number">10</span>;  </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="jdk动态代理实现"><a href="#jdk动态代理实现" class="headerlink" title="jdk动态代理实现"></a>jdk动态代理实现</h3><p><strong>MyInvocationHandler</strong></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyInvocationHandler</span> <span class="keyword">implements</span> <span class="title">InvocationHandler</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> Object target; <span class="comment">//需要代理的真实对象</span></span><br><span class="line">    </span><br><span class="line">    MyInvocationHandler() &#123;</span><br><span class="line">        <span class="keyword">super</span>();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//给需要代理的真实对象赋值</span></span><br><span class="line">    MyInvacationHandler(Object target) &#123;</span><br><span class="line">        <span class="keyword">super</span>();</span><br><span class="line">        <span class="keyword">this</span>.target = target;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function">pulibc Object <span class="title">invoke</span><span class="params">(Object o, Method method, Object[] args)</span> <span class="keyword">throws</span> Throwable </span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(<span class="string">"getName"</span>.equals(method.getName())&#123;</span><br><span class="line">            <span class="comment">//调用真实对象方法前的操作</span></span><br><span class="line">            System.out.println(<span class="string">"++++++before"</span> + method.getName() + <span class="string">"++++++"</span>);</span><br><span class="line">            <span class="comment">//当代理对象调用真实对象的方法时，其会自动的跳转到代理对象关联的handler对象的invoke方法来进行调用</span></span><br><span class="line">            Object result = method.invoke(target,args);</span><br><span class="line">            <span class="comment">//调用真实对象方法前的操作</span></span><br><span class="line">            System.out.println(<span class="string">"++++++after"</span> + method.getName + <span class="string">"++++++"</span>);</span><br><span class="line">            <span class="keyword">return</span> result;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            Object result = method.invoke(target.args);</span><br><span class="line">            <span class="keyword">return</span> result;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>客户端代码</strong></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">    <span class="comment">//① 我们需要代理的真实对象</span></span><br><span class="line">    UserService userService = <span class="keyword">new</span> UserServiceImpl();</span><br><span class="line">    <span class="comment">//② 我们要代理哪个真实对象，就将该对象传进去，最后是通过该真实对象来调用其方法的</span></span><br><span class="line">    InvocationHandler invocationHandler = <span class="keyword">new</span> MyInvocationHandler(userService);</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//③ 通过Proxy的newProxyInstance方法来创建我们的代理对象</span></span><br><span class="line">    UserService userServiceProxy = (UserService)Proxy.newProxyInstance(userService.getClass()</span><br><span class="line">    .getClassLoader(), userService.getClass().getInterfaces(), invocationHandler);</span><br><span class="line">    </span><br><span class="line">    System.out.println(userServiceProxy.getClass().getName());</span><br><span class="line">    System.out.println(userServiceProxy.getName(<span class="number">1</span>));</span><br><span class="line">    System.out.println(UserviceProxy.getAge(<span class="number">1</span>));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">运行结果：</span><br><span class="line">$Proxy0</span><br><span class="line">++++++before getName++++++</span><br><span class="line">------getName------</span><br><span class="line">++++++after getName++++++</span><br><span class="line">Tom</span><br><span class="line">------getAge------</span><br><span class="line">10</span><br></pre></td></tr></table></figure>

<h3 id="代码分析"><a href="#代码分析" class="headerlink" title="代码分析"></a>代码分析</h3><p>可能我们回认为发挥的userServiceProxy对象会是UserService类型的对象，或者是InvocationHandler对象，结果却不是，首先解释一下为什么可以将其转化为UserService类型的对象。<br>原因是：在<code>newProxyInstane()</code>这个方法的第二个参数上，我们给这个代理对象提供了一组什么接口，那么这个代理对象就会实现这组接口，这个时候我们当然可以将这个代理对象转化为这组接口中的任意一个，因为这里的接口是UserService类型，所以就可以将其转换为UserService类型了。<br>同时我们要记住，通过<code>Proxy.newProxyInstance()</code>创建的代理对象是在<code>jvm运行时动态生成的一个对象</code>，它并不是我们的<code>InvocationHandler类型</code>，也不是我们定义的那组接口的类型，而是在运行时动态生成的一个对象，并且命名方式都是这样的形式，以$开头，proxy，然后以数字表示对象的标号。</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">System.out.println(userServiceProxy.getName(<span class="number">1</span>));</span><br><span class="line">System.out.println(UserviceProxy.getAge(<span class="number">1</span>));</span><br></pre></td></tr></table></figure>

<p>这里是通过代理对象来调用实现的那组接口中的方法，这个时候程序就会跳转到由这个代理对象关联到的<code>invocationHandler</code>中的<code>invoke()</code>方法去执行，而我们的<code>invocationHandler</code>对象又接受了一个<code>UserServiceImpl</code>类型的参数，表示我要代理的就是这个真实对象，所以此时就会调用<code>invocationHandler</code>中的<code>invoke()</code>方法执行。</p>
<p>还可以参考：<a href="http://rejoy.iteye.com/blog/1627405" target="_blank" rel="noopener">JDK动态代理实现原理</a></p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2020-03-18T04:04:10.760Z" itemprop="dateUpdated">2020年3月18日 12:04</time>
</span><br>


        这里写留言或版权声明：<a href="/blog/2016/10/04/java/动态代理/" target="_blank" rel="external">http://windynature.oschina.io/2016/10/04/java/动态代理/</a>
    </div>
    <footer>
        <a href="http://windynature.oschina.io">
            <img src="/blog/img/user2.jpg" alt="windy">
            windy
        </a>
    </footer>
</blockquote>

        


        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/动态代理/">动态代理</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://windynature.oschina.io/2016/10/04/java/动态代理/&title=《动态代理机制详解》 — 奔跑的蜗牛&pic=http://windynature.oschina.io/img/user2.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://windynature.oschina.io/2016/10/04/java/动态代理/&title=《动态代理机制详解》 — 奔跑的蜗牛&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://windynature.oschina.io/2016/10/04/java/动态代理/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《动态代理机制详解》 — 奔跑的蜗牛&url=http://windynature.oschina.io/2016/10/04/java/动态代理/&via=http://windynature.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://windynature.oschina.io/2016/10/04/java/动态代理/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/blog/2016/12/23/java/mybatis动态sql语句/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">mybatis动态sql语句</h4>
      </a>
    </div>
  

  
</nav>



    

<div class="comments" id="comments">
    <div class="ds-thread" data-thread-key="java/动态代理" data-title="动态代理机制详解" data-url="http://windynature.oschina.io/2016/10/04/java/动态代理/"></div>
</div>
<script>
lazyScripts.push('//cdn.bootcss.com/marked/0.3.6/marked.min.js');

var duoshuoQuery = {short_name:'ysblog', theme: 'none'};
lazyScripts.push('//unpkg.com/hexo-theme-material-indigo@1.5.2/js/embed.min.js');


</script>










</article>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a></span>
            <span>奔跑的蜗牛 &copy; 2015 - 2020</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://windynature.oschina.io/2016/10/04/java/动态代理/&title=《动态代理机制详解》 — 奔跑的蜗牛&pic=http://windynature.oschina.io/img/user2.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://windynature.oschina.io/2016/10/04/java/动态代理/&title=《动态代理机制详解》 — 奔跑的蜗牛&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://windynature.oschina.io/2016/10/04/java/动态代理/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《动态代理机制详解》 — 奔跑的蜗牛&url=http://windynature.oschina.io/2016/10/04/java/动态代理/&via=http://windynature.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://windynature.oschina.io/2016/10/04/java/动态代理/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/blog/', SHARE: true, REWARD: false };



</script>

<script src="//unpkg.com/hexo-theme-material-indigo@1.5.2/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@1.5.2/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
